package com.zzptc.easyshop.servlet;

import org.apache.taglibs.standard.lang.jstl.NullLiteral;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
@WebServlet(name = "LoginCookieServlet")
public class LoginCookieServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter( "name" );
        String pwd = request.getParameter( "pwd" );
    //创建Cookie对象
        Cookie coo = new Cookie( "uname",name);
        Cookie coo1 = new Cookie( "upwd",pwd);
        coo.setMaxAge(10*24*60*60);//保存10天
        coo1.setMaxAge(10*24*60*60);
        response.addCookie( coo );
        response.addCookie( coo1 );
    }
//    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost( request,response );
    }
}
